package com.kgc.rb.service.impl;

import com.kgc.rb.mapper.QgOrderMapper;
import com.kgc.rb.pojo.QgOrder;
import com.kgc.rb.service.QgOrderService;
import com.alibaba.dubbo.config.annotation.Service;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.ArrayList;
import java.util.HashMap;

@Component
@Service(interfaceClass = QgOrderService.class)
public class QgOrderServiceImpl implements QgOrderService {

    @Resource
    private QgOrderMapper qgOrderMapper;

    @Override
    public QgOrder getQgOrderById(String id) throws Exception {
        return qgOrderMapper.getQgOrderById(id);
    }

    @Override
    public List<QgOrder> getQgOrderListByMap(Map<String, Object> param) throws Exception {
        return qgOrderMapper.getQgOrderListByMap(param);
    }

    @Override
    public Integer getQgOrderCountByMap(Map<String, Object> param) throws Exception {
        return qgOrderMapper.getQgOrderCountByMap(param);
    }

    @Override
    public Integer qdtxAddQgOrder(QgOrder qgOrder) throws Exception {
        //qgOrder.setCreatedTime(new Date());
        return qgOrderMapper.insertQgOrder(qgOrder);
    }

    @Override
    public Integer qdtxModifyQgOrder(QgOrder qgOrder) throws Exception {
        //qgOrder.setUpdatedTime(new Date());
        return qgOrderMapper.updateQgOrder(qgOrder);
    }

    @Override
    public Integer qdtxDeleteQgOrderById(String id) throws Exception {
        return qgOrderMapper.deleteQgOrderById(id);
    }

    @Override
    public Integer qdtxBatchDeleteQgOrder(String ids) throws Exception {
        Map<String, List<String>> param = new HashMap<String, List<String>>();
        String[] paramArrays = ids.split(",");
        List<String> idList = new ArrayList<String>();
        for (String temp : paramArrays) {
            idList.add(temp);
        }
        param.put("ids", idList);
        return qgOrderMapper.batchDeleteQgOrder(param);
    }


}
